import '../public.dart';

class ClientUserApi {
  /// 修改用户
  /// /clientUser/update
  static Future<BaseResponse<void>> update_2(ClientUserUpdateDto params) async {
    final response = await HttpUtil().request(
      '/clientUser/update',
      method: 'POST',
      data: params.toJson(),
    );
    return BaseResponse<void>.fromJson(response);
  }

  /// 查询当前用户有无PIN码
  /// /clientUser/queryPinExists
  static Future<BaseResponse<QueryPinResponseDto>> queryPinExists() async {
    final response = await HttpUtil().request(
      '/clientUser/queryPinExists',
      method: 'POST',
    );
    return BaseResponse<QueryPinResponseDto>.fromJson(
      response,
      fromJsonT: (json) =>
          QueryPinResponseDto.fromJson(json as Map<String, dynamic>),
    );
  }

  /// 验证PIN码
  /// /clientUser/checkPin
  static Future<BaseResponse<CheckPinResponseDto>> checkPin(
    CheckPinDto params,
  ) async {
    final response = await HttpUtil().request(
      '/clientUser/checkPin',
      method: 'POST',
      data: params.toJson(),
    );
    return BaseResponse<CheckPinResponseDto>.fromJson(
      response,
      fromJsonT: (json) =>
          CheckPinResponseDto.fromJson(json as Map<String, dynamic>),
    );
  }

  /// 修改PIN码
  /// /clientUser/changePin
  static Future<BaseResponse<void>> changePin(ChangePinDto params) async {
    final response = await HttpUtil().request(
      '/clientUser/changePin',
      method: 'POST',
      data: params.toJson(),
    );
    return BaseResponse<void>.fromJson(response);
  }

  /// 修改登录密码
  /// /clientUser/changePassword
  static Future<BaseResponse<void>> changePassword_1(
    ChangePasswordDto params,
  ) async {
    final response = await HttpUtil().request(
      '/clientUser/changePassword',
      method: 'POST',
      data: params.toJson(),
    );
    return BaseResponse<void>.fromJson(response);
  }

  /// 获取用户等级信息列表
  /// /clientUser/getUserLevelList
  static Future<BaseResponse<List<SysUserLevelEntity>>>
  getUserLevelList() async {
    final response = await HttpUtil().request(
      '/clientUser/getUserLevelList',
      method: 'GET',
    );
    return BaseResponse<List<SysUserLevelEntity>>.fromJson(
      response,
      fromJsonT: (json) =>
          (json as List).map((e) => SysUserLevelEntity.fromJson(e)).toList(),
    );
  }

  /// 获取个人信息
  /// /clientUser/getProfile
  static Future<BaseResponse<ClientProfileDto>> getProfile() async {
    final response = await HttpUtil().request(
      '/clientUser/getProfile',
      method: 'GET',
    );
    return BaseResponse<ClientProfileDto>.fromJson(
      response,
      fromJsonT: (json) =>
          ClientProfileDto.fromJson(json as Map<String, dynamic>),
    );
  }

  /// 获取余额
  /// /clientUser/getAvailableBalance
  static Future<BaseResponse<int>> getAvailableBalance() async {
    final response = await HttpUtil().request(
      '/clientUser/getAvailableBalance',
      method: 'GET',
    );
    return BaseResponse<int>.fromJson(response);
  }

  /// 删除用户
  /// /clientUser/delete
  static Future<BaseResponse<void>> delete_1() async {
    final response = await HttpUtil().request(
      '/clientUser/delete',
      method: 'DELETE',
    );
    return BaseResponse<void>.fromJson(response);
  }
}
